package com.william.modules.william.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.william.modules.test.entity.SysSecond;
import com.william.modules.test.service.ISysSecondService;
import com.william.modules.william.entity.SysMain;
import com.william.modules.william.mapper.SysMainMapper;
import com.william.modules.william.service.ISysMainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SysMainServiceImpl extends ServiceImpl<SysMainMapper, SysMain> implements ISysMainService {
    @Autowired
    private ISysSecondService sysSecondService;

    @Override
    public void synchData() {
        List<SysMain> list = this.list();
        List<SysSecond> sysSeconds = JSONArray.parseArray(JSON.toJSONString(list), SysSecond.class);
        sysSecondService.saveOrUpdateBatch(sysSeconds);
    }
}
